<!DOCTYPE html>
<html>

<head>
  <meta charset="utf-8" />
  <meta http-equiv="X-UA-Compatible" content="IE=edge" />
  <meta name="viewport" content="initial-scale=1.0, user-scalable=no, width=device-width" />
  <title>HELLO, AMAP!</title>
  <style>
    html,
    body,
    #container {
      width: 100%;
      height: 100%;
    }
  </style>
</head>

<body>
  <div id="container"></div>
</body>
<script type="text/javascript">
  window._AMapSecurityConfig = {
    securityJsCode: "d522601a6afc7f91796728190ea8748a",
  };
</script>
<script src="https://webapi.amap.com/maps?v=1.4.15&key=6b3a0bf04070a13557dbc45fae249ada"></script>
<script type="text/javascript">
  var map = new AMap.Map("container", {
    zoom: 16, //级别
    center: [121.47592, 31.237687], //中心点坐标
  })
  // const points = [
  //   { keyword: '文冲（地铁站）', city: '广州' }, //起始点坐标
  //   { keyword: '江泰路（地铁站）', city: '广州' } //终点坐标
  // ]
  function beginDriver(begin,end){
    const points = [
    { keyword: begin }, //起始点坐标
    { keyword: end } //终点坐标
  ]
    //引入和创建驾车规划插件
  AMap.plugin(["AMap.Driving"], function () {
    const driving = new AMap.Driving({
      map: map,
      //panel: "my-panel", //参数值为你页面定义容器的 id 值<div id="my-panel"></div>
      //策略:时间最短
      policy:AMap.DrivingPolicy.LEAST_TIME
    });
    //获取起终点规划线路
    driving.search(points, function (status, result) {
      if (status === "complete") {
        //status：complete 表示查询成功，no_data 为查询无结果，error 代表查询错误
        //查询成功时，result 即为对应的驾车导航信息
        console.log(result);
      } else {
        console.log("获取驾车数据失败：" + result);
      }
    });
  });
  }

  

</script>

</html>